#include "stdafx.h"
#define __RedDogClient__
#include "..\common\GameDefine.h"
#include "GFSRealWnd.h"
#include "GameMainWnd.h"
//
#include "GameKernel.h"

using namespace ACTIVECTRL;

#define STDCLIENTMETHD(method) HRESULT STDMETHODCALLTYPE CGameMainWnd::method
#define STDCLIENTMETHD_(rettype, method) rettype STDMETHODCALLTYPE CGameMainWnd::method

EXPOSE_GAMECREATOR_SUPPORTSITE(FINAL_EXPORT_CLASS, GAMEID, MAKEWORD(1,1), 1124, 700)

STDCLIENTMETHD_(HRESULT, QueryInterface)(REFIID riid, void** ppvObject)
{
    if(ppvObject == NULL) return E_INVALIDARG;
    *ppvObject = NULL;
    if(riid == IID_IGameConst)
        *ppvObject = static_cast<IGameConst*>(this);
    else if(riid == IID_IGameRender)
        *ppvObject = static_cast<IGameRender*>(this);
    else if(riid == IID_IPlayerIOEvent)
        *ppvObject = static_cast<IPlayerIOEvent*>(this);
    else
        return E_NOTIMPL;
    return S_OK;
}

STDCLIENTMETHD_(ULONG, AddRef)()
{
    return 1;
}

STDCLIENTMETHD_(ULONG, Release)()
{
    delete this;
    return 0;
}

STDCLIENTMETHD(GetEstimateTime)(DWORD* pMillisecond)
{
    *pMillisecond = 3000;
    return S_OK;
}

STDCLIENTMETHD(GetPlayerNum)(IGameConst::PLAYERNUMBER* pNumber)
{
    pNumber->nMaintenance = 1;
    pNumber->nMax = 1;
    pNumber->nStart = 0;
    return S_OK;
}

STDCLIENTMETHD(GetGameIdentifier)(char* pIdentifier)
{
    _snprintf(pIdentifier, 32, APPLICATION_NAME);
    return S_OK;
}

STDCLIENTMETHD(GetVersion)(VERSION_STRUCT* pVersionStruct)
{
    pVersionStruct->curVersion = MAKELONG(1,1);
    pVersionStruct->minVersion = MAKELONG(1,1);
    pVersionStruct->maxVersion = MAKELONG(1,1);
    return S_OK;
}

STDCLIENTMETHD(SetClientSite)(IClientSite* pSite)
{
    m_pSite = pSite;
    m_pSite->AddRef();
    return S_OK;
}

STDCLIENTMETHD(OnInitialize)()
{
    m_pSite->GetMyself(&m_pMyself);
    return S_OK;
}

STDCLIENTMETHD(OnWaitingStart)()
{
    return S_OK;
}

STDCLIENTMETHD(OnGameStart)()
{
    return S_OK;
}

STDCLIENTMETHD(OnGameEnd)(void* lpScoreBuf)
{
    return S_OK;
}

STDCLIENTMETHD(OnSceneChanged)(SCENE* pScene)
{
    return S_OK;
}

STDCLIENTMETHD(Stop)(char* pReason)
{
    return S_OK;
}

STDCLIENTMETHD(OnPlayerStateChanged)(int, int, IGamePlayer*)
{
    return S_OK;
}

STDCLIENTMETHD(OnGameOperation)(int, LPOPDATA, int)
{
    return S_OK;
}

STDCLIENTMETHD(RequestConfirmQuit)()
{
    return S_OK;
}

STDCLIENTMETHD(Clear)()
{
    return S_OK;
}

STDCLIENTMETHD(OnUserEnter)(int, IGamePlayer*)
{
    return S_OK;
}

STDCLIENTMETHD(OnUserExit)(int, IGamePlayer*)
{
    return S_OK;
}

STDCLIENTMETHD(OnUserOffline)(int, IGamePlayer*)
{
    return S_OK;
}

STDCLIENTMETHD(OnUserReplay)(int, IGamePlayer*)
{
    return S_OK;
}

STDCLIENTMETHD(OnFrameConnected)(IClientFrame* pFrame)
{
    pFrame->setWindowText(APPLICATION_NAME);
    return S_OK;
}

STDCLIENTMETHD(QueryRender)(IGameRender** ppRender)
{
    *ppRender = static_cast<IGameRender*>(this);
    return S_OK;
}

STDCLIENTMETHD(GetGameDescription)(char* pName, char* pDesc)
{
    ASSERT(pName && pDesc);
    strcpy(pName, APPLICATION_NAME);
    pDesc[0] = 0;
    return S_OK;
}